package com.lanyou.esb.cook.proxy.redis.proxy.impl;

import java.util.HashMap;
import java.util.Map;

import com.lanyou.esb.cook.proxy.common.Constants;
import com.lanyou.esb.cook.proxy.common.Constants4Redis;
import com.lanyou.esb.cook.proxy.entity.IfReqQuantity;
import com.lanyou.esb.cook.proxy.redis.proxy.base.BaseHashJedisProxy;

/**
 * 接口请求量控制Redis操作代理
 * 
 * @author Davey.wu
 */
public class IfReqQuantityJedisProxy extends BaseHashJedisProxy<IfReqQuantity> {

	public IfReqQuantityJedisProxy() {
		this.setKey(Constants4Redis.REDIS_HASH_KEY_IRQ);
		Map<String, Integer> keyFields = new HashMap<>();
		/** field的组成：接口标识，请求时间单位 **/
		keyFields.put(Constants.INTERFACE_ID, 0);
		keyFields.put(Constants.REQUEST_UNIT, 1);
		this.setFields(keyFields);
	}

	@Override
	public Map<String, String> getKeyMap(IfReqQuantity target) {
		Map<String, String> map = new HashMap<>(4);
		map.put(Constants.INTERFACE_ID, target.getIfId());
		map.put(Constants.REQUEST_UNIT, target.getReqUnit());
		return map;
	}

}
